﻿using System.Collections.Generic;
using System.ComponentModel;
using Newtonsoft.Json;

namespace Amba.NoteList.Settings
{

    public class CustomFieldDefinition
    {
        [JsonProperty(PropertyName = "name")]
        public string Name { get; set; }
        [JsonProperty(PropertyName = "displayName")]
        public string DisplayName { get; set; }
        [JsonProperty(PropertyName = "type")]
        public string Type { get; set; }
    }

    public class NoteListFieldSettings
    {
        public string Hint { get; set; }

        private string _customProperties;

        public string CustomProperties
        {
            get
            {
                if (string.IsNullOrWhiteSpace(_customProperties))
                    _customProperties = "[]";
                return _customProperties;
            }
            set { _customProperties = value; }
        }

        public IEnumerable<CustomFieldDefinition> CustomFieldsList
        {
            get { return JsonConvert.DeserializeObject<List<CustomFieldDefinition>>(CustomProperties); }
        }        
    }
}